-
Notifications
You must be signed in to change notification settings - Fork 192
Add missing hooks for callbacks. #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -172,7 +178,7 @@ public void setEntityCallbacks(EntityCallbacks entityCallbacks) { | |||
this.entityCallbacks = entityCallbacks; | |||
} | |||
|
|||
void maybeEmitEvent(CouchbaseMappingEvent<?> event) { | |||
public void maybeEmitEvent(CouchbaseMappingEvent<?> event) { | |||
if (canPublishEvent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to call from ReactiveRemoveByIdOperationSupport
@@ -95,16 +96,21 @@ public CouchbaseDocument encodeEntity(final Object entityToEncode) { | |||
} | |||
|
|||
@Override | |||
public Object applyUpdatedCas(final Object entity, final long cas) { | |||
public Object applyUpdatedCas(final Object entity, CouchbaseDocument converted, final long cas) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added converted CouchbaseDocument to args as AfterSaveEvent takes a CouchbaseDocument.
*/ | ||
T onAfterConvert(T entity, Document document, String collection); | ||
T onAfterConvert(T entity, CouchbaseDocument document, String collection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied incorrectly from Mongo with the second arg of Document instead of CouchbaseDocument.
@@ -33,17 +35,19 @@ | |||
* @author Mark Paluch | |||
* @author Michael Reiche | |||
*/ | |||
public class AuditingEventListener implements ApplicationListener<BeforeConvertEvent<Object>> { | |||
public class AuditingEventListener implements ApplicationListener<CouchbaseMappingEvent<Object>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support any CouchbaseMappingEvent. Not just BeforeConvertEvent.
*/ | ||
@Override | ||
public Publisher<Object> onAfterConvert(Object entity, CouchbaseDocument document, String collection) { | ||
LOG.debug("onAfterConvert " + document.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should remove this debug.
2aba7f2
to
615f873
Compare
615f873
to
ed3d923
Compare
1) the previous change (#955) to CouchbaseAuditingRegister intended to register AuditingEntityCallback instead of AuditingEventListener but only changed the name that AuditingEventListener was registered with. Since AuditingEventListener does exactly the same thing as AuditingEntityCallback, it behaved as those AuditingEntityCallback was being used. 2) It seems that the two mechanisms - EntityCallback and EventListener both do more-or-less the same thing. I'm not sure why there are two mechanisms to do the same thing. 3) Although the ReactiveAuditingEntityCallback mechanism is triggered only for reactive operations and the non-reactive AuditingEntityCallback is triggered only for non-reactive operations, the events are triggered for both. Since there was a desire to have distinct callbacks for reactive/non-reactive operations, I also made distinct events for reactive/non-reactive operations. However both the reactive and non-reactive event mechanisms are triggered for either reactive and non-reactive operations, so it is necessary for the mechanism to determine if it should act on the event. 4) Although there is an AbstractCouchbaseEventListener that is extended by LoggingEventListener and ValidatingEventListener, AuditingEventListener does not extend it (maybe it should). Closes #1074.
ed3d923
to
b311c6f
Compare
1) the previous change (#955) to CouchbaseAuditingRegister intended to register AuditingEntityCallback instead of AuditingEventListener but only changed the name that AuditingEventListener was registered with. Since AuditingEventListener does exactly the same thing as AuditingEntityCallback, it behaved as those AuditingEntityCallback was being used. 2) It seems that the two mechanisms - EntityCallback and EventListener both do more-or-less the same thing. I'm not sure why there are two mechanisms to do the same thing. 3) Although the ReactiveAuditingEntityCallback mechanism is triggered only for reactive operations and the non-reactive AuditingEntityCallback is triggered only for non-reactive operations, the events are triggered for both. Since there was a desire to have distinct callbacks for reactive/non-reactive operations, I also made distinct events for reactive/non-reactive operations. However both the reactive and non-reactive event mechanisms are triggered for either reactive and non-reactive operations, so it is necessary for the mechanism to determine if it should act on the event. 4) Although there is an AbstractCouchbaseEventListener that is extended by LoggingEventListener and ValidatingEventListener, AuditingEventListener does not extend it (maybe it should). Closes #1074. Co-authored-by: mikereiche <michael.reiche@couchbase.com>
the previous change (Add @EnableReactiveCouchbaseAuditing [DATACOUCH-644] #955) to CouchbaseAuditingRegister intended to register
AuditingEntityCallback instead of AuditingEventListener but only changed the
name that AuditingEventListener was registered with. Since
AuditingEventListener does exactly the same thing as AuditingEntityCallback,
it behaved as those AuditingEntityCallback was being used.
It seems that the two mechanisms - EntityCallback and EventListener
both do more-or-less the same thing. I'm not sure why there are two
mechanisms to do the same thing.
Although the ReactiveAuditingEntityCallback mechanism is triggered
only for reactive operations and the non-reactive AuditingEntityCallback
is triggered only for non-reactive operations, the events are triggered
for both. Since there was a desire to have distinct callbacks for
reactive/non-reactive operations, I also made distinct events for
reactive/non-reactive operations. However both the reactive and non-reactive
event mechanisms are triggered for either reactive and non-reactive operations,
so it is necessary for the mechanism to determine if it should act on the
event.
Although there is an AbstractCouchbaseEventListener that is extended by
LoggingEventListener and ValidatingEventListener, AuditingEventListener does
not extend it (maybe it should).
Closes #1074.